#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
int main()
{
	int m, n;
	scanf("%d %d", &m, &n);
	int arr1[1000] = { 0 };
	int arr2[1000] = { 0 };
	int i = 0;
	int j = 0;
	int k;
	for (k = 0; k < m; k++)
	{
		scanf("%d", &arr1[k]);
	}
	for (k = 0; k < n; k++)
	{
		scanf("%d", &arr2[k]);
	}
	while (i < m && j < n)
	{
		if (arr1[i] < arr2[j])
		{
			printf("%d ", arr1[i++]);
		}
		else
		{
			printf("%d ", arr2[j++]);
		}
	}
	while (i < m)
	{
		printf("%d ", arr1[i++]);
	}
	while (j < n)
	{
		printf("%d ", arr2[j++]);
	}
	return 0;
}